package com.bidu.web;


import com.bidu.common.SpringContextUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tang.tang on 16/12/23.
 */

/**
 * 关于事务管理器，
 * 不管是JPA还是JDBC等都实现自接口
 * PlatformTransactionManager
 * 如果你添加的是 spring-boot-starter-jdbc 依赖，
 * 框架会默认注入 DataSourceTransactionManager 实例。
 * 如果你添加的是 spring-boot-starter-data-jpa 依赖，（本项目中采用的）
 * 框架会默认注入 JpaTransactionManager 实例
 */
@EnableTransactionManagement  //开启事务管理器 使用默认的事务管理器
@SpringBootApplication
@RestController
//@ComponentScan(basePackages={""})
//配置启动时的扫包路径,默认当前包
@ImportResource({"classpath:spring-config.xml"})
@MapperScan("com.bidu.model")
@EnableScheduling
public class Application {

    private static Logger LOGGER = LoggerFactory.getLogger(Application.class);

    /**
     * 项目主入口
     */
    public static void main(String[] args) {
        LOGGER.info("Spring Boot RUN Application Beginning......");
        System.setProperty("java.security.egd", "file:/dev/urandom");
        SpringApplication app = new SpringApplication(Application.class);
        //关闭Banner(图标标记)
//        app.setShowBanner(false);
        ApplicationContext context = app.run(args);
        SpringContextUtil.setApplicationContext(context);
        LOGGER.info("Spring Boot RUN Application  Successfully!");

    }


}
